const app = getApp();
Page({
  data: {
    languages: ['中文', 'English'],
    selectedLanguage: '中文',
    banners: [ ],
    products: [],
    details: []
  },
  getProducts() {
    wx.request({
      url: `${app.globalData.baseUrl}/category/topList`,
      method: 'GET',
      success: (res) => {
        console.log('llll',res.data)
        this.setData({ products: res.data.data });
      }
    });
  },
  onSearch(e) {
    const value = e.detail.value;
    // 可在此实现商品筛选搜索逻辑
  },
  onProductTap(item) {
    console.log('item',item)
    wx.navigateTo({
      url: `/pages/category/category?categoryId=${item.currentTarget.dataset.id}&categoryName=${item.currentTarget.dataset.name}`,
    });
  },
  onLoad() {
    this.getProducts();
  }
});